package br.edu.ufcg.ga;

import org.jgap.Configuration;
import org.jgap.InvalidConfigurationException;

import br.edu.ufcg.ga.population.InitialPopulationGenerator;

public class CVConfiguration {

	Configuration configuration = null;

	private int maxGenerations;

	private int maxRepetitionBestFitness;

	private boolean collectData;

	// Wrapper Double and not primitive double because it's an optional option
	private Double optimalValueStopCondition;

	private InitialPopulationGenerator initialPopulationGenerator;

	private long seed;

	public CVConfiguration() {
		this.configuration = new Configuration();
	}

	public Configuration getConfiguration() {
		return configuration;
	}

	public int getPopSize() {
		return configuration.getPopulationSize();
	}

	public void setPopSize(int popSize) {
		try {
			this.configuration.setPopulationSize(popSize);
		} catch (InvalidConfigurationException e) {
			// TODO Handle this error or throw another exception (i.e. not RuntimeException)
			throw new RuntimeException(e);
		}
	}

	public int getMaxGenerations() {
		return maxGenerations;
	}

	public void setMaxGenerations(int maxGenerations) {
		this.maxGenerations = maxGenerations;
	}

	public int getMaxRepetitionBestFitness() {
		return maxRepetitionBestFitness;
	}

	public void setMaxRepetitionBestFitness(int maxRepetitionBestFitness) {
		this.maxRepetitionBestFitness = maxRepetitionBestFitness;
	}

	public boolean isCollectData() {
		return collectData;
	}

	public void setCollectData(boolean collectData) {
		this.collectData = collectData;
	}

	public Double getOptimalValueStopCondition() {
		return optimalValueStopCondition;
	}

	public void setOptimalValueStopCondition(Double optimalValueStopCondition) {
		this.optimalValueStopCondition = optimalValueStopCondition;
	}

	public boolean isElithism() {
		return this.configuration.isPreserveFittestIndividual();
	}

	public void setElithism(boolean elithism) {
		this.configuration.setPreservFittestIndividual(elithism);
	}

	public InitialPopulationGenerator getInitialPopulationGenerator() {
		return initialPopulationGenerator;
	}

	public void setInitialPopulationGenerator(InitialPopulationGenerator initialPopulationGenerator) {
		this.initialPopulationGenerator = initialPopulationGenerator;
	}

	public long getSeed() {
		return seed;
	}

	public void setSeed(long seed) {
		this.seed = seed;
	}

}
